<?php
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );
RClassesImporter::cls("dbo.dtos.DownloadDTO" );

class DownloadModel {
	
	function delete($arrId) {
		$result = false;
		if (is_array($arrId)) {
			$arrId = implode(',', $arrId);
		}
		$sQuery		=	"DELETE FROM download  WHERE download_id IN ({$arrId}) ";
		return SysDatabase::execute( $sQuery );
	}	
	
	function getDownloadDetails($id) {
		$my_Obj = new DownloadDTO();
		$my_Obj->setKeyValue($id);
		SysDatabase::fillData($my_Obj);
		return $my_Obj;
	}
	function loadFiles(){
		$sql = "SELECT * FROM download ";
		return SysDatabase::loadObjectList($sql);
	}
	
	function saveDownloadDTO($dto){
		return SysDatabase::saveDTO($dto);
	}
		
	
	function getTranscationLog($id) {
		$finder = new TranscationFinder();
		$finder->member_id = $id;
		return SysDatabase::getSelectResult($finder->getSelectSQL());
	}
	
	function loadFileType(){
		$file_type_id = SysRequest::getVar("task");
		$sql = "SELECT * FROM download dl LEFT JOIN file_type ft ON ft.file_type_id = '$file_type_id' WHERE dl.file_type_id = ft.file_type_id"; 
		return  SysDatabase::loadObjectList($sql);
		
	}
	
}
?>